﻿@using OBUCare.Web.Models;
@using OBUCare.Core.Models;
@using OBUCare.Web.Infrastructure;
@using OBUCare.Core.BL;
@using OBUCare.Core.Common;

@{
    ObuDropDownListHlper ddlHelper = new ObuDropDownListHlper();

    //获取所有的资金来源
    var fundTypes = ddlHelper.GetDataSource(ConfigMgr.tblFundType, true, null, false, null);
    int i = 1;
    var r = fundTypes.Where(c => c.Text == "现金").FirstOrDefault();
    string idCash = "0";
    if (r != null)
    {
        idCash = r.Value;
    }
    
}
<table style="width: 100%;">
    @foreach (var f in fundTypes)
    {
        string id = f.Value;
        <tr>
            <td>
                来源 @i：
            </td>
            <td>
                @Html.Telerik().DropDownList().Name("FUND_FROM" + id).BindTo(ddlHelper.GetDataSource(ConfigMgr.tblFundType, true, idCash, false, null)).HtmlAttributes(new { style = "width:100px;",value=id }).ClientEvents(e => e.OnChange("changeShow"))
            </td>
            <td>
                金额：
            </td>
            <td>
                @* @Html.Telerik().NumericTextBox().Name("AMOUNT" + id).InputHtmlAttributes(new { style = "width:100px;", onchange = "javascript:changeTotal(this);" }).EmptyMessage("请输入金额！").MinValue(0)*@
                @Html.TextBox("AMOUNT" + id, "", new { style = "width:138px;height:15px" })
            </td>
            <td>
                说明：
            </td>
            <td>
                @Html.TextBox("REMARK" + id, "", new { style = "width:100px;height:15px" })
            </td>
            <td>
                <table id="tbCheque@{@id}" style="display:none;">
                    <tr>
                        <td>
                            支票号：
                        </td>
                        <td>
                            @Html.TextBox("FUND_NO" + id, "", new { style = "width:100px;height:15px" })
                        </td>
                        <td>
                            @Html.Label("支票过期日期：")
                        </td>
                        <td>
                            @Html.Telerik().DatePicker().Name("CHEQUE_EXPIRE_TIME" + id).ShowButton(false).OpenOnFocus(true).HtmlAttributes(new { style = "width:100px;"})
                        </td>
                    </tr>
                </table>
                <table id="tbPOS@{@id}" style="display: none;">
                    <tr>
                        <td>
                            POS号：
                        </td>
                        <td>
                            @Html.TextBox("FUND_NO" + id, "", new { style = "width:100px;height:15px" })
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        
        i++;
    }
</table>
<script type="text/javascript">
    function changeShow(e) {
        //debugger;
        var value = e.currentTarget.parentElement.parentElement.children[0].value;    
        if (e.value == "1") {
            $('#tbCheque' + value).attr("style", "display:inline;");
            $('#tbPOS' + value).attr("style", "display:none;");
//            document.getElementById("CHEQUE_EXPIRE_TIME" + value).disabled = true;
        } else
            if (e.value == "3") {
                $('#tbPOS' + value).attr("style", "display:inline;");
                $('#tbCheque' + value).attr("style", "display:none;");
//                document.getElementById("CHEQUE_EXPIRE_TIME" + value).disabled = false;
            }
            else {
                $('#tbPOS' + value).attr("style", "display:none;");
                $('#tbCheque' + value).attr("style", "display:none;");
//                document.getElementById("CHEQUE_EXPIRE_TIME" + value).disabled =false;
            }
    }
</script>
@*<table style="width: 100%;">
    @foreach (var f in fundTypes)
    {
        string id = f.Value;
        string checkLbl = "";
        string checkExpireLbl = "";
        if (id.Equals(ConfigMgr.tblFundType_Check))
        {
            checkLbl = "支票号：";
            checkExpireLbl = "支票过期日期：";
        }
        else if (id.Equals(ConfigMgr.tblFundType_Pos))
        { checkLbl = "POS流水号："; }
        
        
        <tr>
            <td>
                来源 @i：
            </td>
            <td>
                @Html.Telerik().DropDownList().Name("FUND_FROM" + id).BindTo(ddlHelper.GetDataSource(ConfigMgr.tblFundType, true, idCash, false, null)).HtmlAttributes(new { style = "width:100px;", onchange = "javascript:changeShow(" + i + ");" })
            </td>
            <td>
                金额：
            </td>
            <td>
                 @Html.Telerik().NumericTextBox().Name("AMOUNT" + id).InputHtmlAttributes(new { style = "width:100px;", onchange = "javascript:changeTotal(this);" }).EmptyMessage("请输入金额！").MinValue(0)
                @Html.TextBox("AMOUNT" + id, "", new { style = "width:138px;height:15px" })
            </td>
            <td>
                说明：
            </td>
            <td>
                @Html.TextBox("REMARK" + id, "", new { style = "width:100px;height:15px" })
            </td>
            <td>
                @checkLbl
            </td>
            <td>
                @if (!checkLbl.IsNullOrEmpty())
                {   
                    @Html.TextBox("FUND_NO" + id, "", new { style = "width:100px;height:15px" })
                }
            </td>
            <td>
                @checkExpireLbl
            </td>
            <td>
                @if (!checkExpireLbl.IsNullOrEmpty())
                {
                    @Html.Telerik().DatePicker().Name("CHEQUE_EXPIRE_TIME" + id).ShowButton(false).OpenOnFocus(true).HtmlAttributes(new { style = "width:100px;" })
                }
            </td>
        </tr>
        
                i++;
    }
</table>*@
@{
    ddlHelper.Dispose();    
}
